<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .ad{
            position: relative;
            width:600px;
            height:500px;
            margin: auto;
        }
        .ad img{
            width: 400px;
            height:400px;
            position: absolute;
            top: 50px;
            left: 100px;
        }
        .ad p{
            text-align: center;
            font-size: 15px;
            color: black;
        
        }
    </style>
</head>
<body>
    <div class="ad">
        <p></p>
        <img src="image/true.jpg" alt="" class="ad_img">
    </div>
    <script>
        let ad=document.querySelector('.ad');
        let tip=document.querySelector('p');
        let time=3;
        fn();
        let timer=setInterval(fn,1000);
        function fn(){
            if(time==0){
                ad.style.display='none';
                clearInterval(timer);
            }
            tip.innerHTML=time+'秒后自动关闭广告';
            time--;
        }
    </script>
</body>
</html>